
package com.shop.cloud.mall.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.cloud.common.core.util.R;
import com.shop.cloud.common.log.annotation.SysLog;
import com.shop.cloud.mall.common.entity.SupplierGoodsSku;
import com.shop.cloud.mall.admin.service.SupplierGoodsSkuService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 * 供应商sku表
 *
 * @author 
 * @date 2024-11-06 10:10:09
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/suppliergoodssku")
@Tag(description = "suppliergoodssku", name = "供应商sku表管理")
public class SupplierGoodsSkuController {

    private final SupplierGoodsSkuService supplierGoodsSkuService;

    /**
     * 供应商sku表分页列表
     * @param page 分页对象
     * @param supplierGoodsSku 供应商sku表
     * @return
     */
    @Operation(summary = "供应商sku表分页列表")
    @GetMapping("/page")
    @PreAuthorize("@ato.hasAuthority('mall:suppliergoodssku:index')")
    public R getPage(Page page, SupplierGoodsSku supplierGoodsSku) {
        return R.ok(supplierGoodsSkuService.page(page, Wrappers.query(supplierGoodsSku)));
    }

    /**
     * 供应商sku表查询
     * @param id
     * @return R
     */
    @Operation(summary = "供应商sku表查询")
    @GetMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:suppliergoodssku:get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(supplierGoodsSkuService.getById(id));
    }

    /**
     * 供应商sku表新增
     * @param supplierGoodsSku 供应商sku表
     * @return R
     */
    @Operation(summary = "供应商sku表新增")
    @SysLog("新增供应商sku表")
    @PostMapping
    @PreAuthorize("@ato.hasAuthority('mall:suppliergoodssku:add')")
    public R save(@RequestBody SupplierGoodsSku supplierGoodsSku) {
        return R.ok(supplierGoodsSkuService.save(supplierGoodsSku));
    }

    /**
     * 供应商sku表修改
     * @param supplierGoodsSku 供应商sku表
     * @return R
     */
    @Operation(summary = "供应商sku表修改")
    @SysLog("修改供应商sku表")
    @PutMapping
    @PreAuthorize("@ato.hasAuthority('mall:suppliergoodssku:edit')")
    public R updateById(@RequestBody SupplierGoodsSku supplierGoodsSku) {
        return R.ok(supplierGoodsSkuService.updateById(supplierGoodsSku));
    }

    /**
     * 供应商sku表删除
     * @param id
     * @return R
     */
    @Operation(summary = "供应商sku表删除")
    @SysLog("删除供应商sku表")
    @DeleteMapping("/{id}")
    @PreAuthorize("@ato.hasAuthority('mall:suppliergoodssku:del')")
    public R removeById(@PathVariable String id) {
        return R.ok(supplierGoodsSkuService.removeById(id));
    }

}
